Adding some more judges, here and there.
[andmenj-acm.git] / Google Code Jam / 2010 / Qualification round / b-fair / b.rb
blob69cc2f2e3e977df9b907077dccc60d61a5b34a4d
1 require 'rubygems'
3 t = readline.to_i
4 t.times do |kase|
5   print "Case #%d: " % (kase + 1)
6   a = readline.split.collect { |k| k.to_i }
7   a.shift
9   small = a.min
10   b = a.collect { |k| k - small }
11   g = b.first.to_i
12   1.upto(b.size - 1) do |i|
13     g = g.gcd(b[i])
14   end
15   puts ((g - small) % g + g) % g
16 end